﻿<%@ WebHandler Language="C#" Class="wxMiniProgramLogin" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;
using System.Collections;

public class wxMiniProgramLogin : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";


        string authHeader = context.Request.Headers["token"];//Header中的token
        if (string.IsNullOrEmpty(authHeader))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }

        using (Entities bll = new Entities())
        {
            ArrayList listjson = new ArrayList();
            foreach (var item in new int[]{ 99})
            {
                         var x = bll.S_Goods.FirstOrDefault();
            var GetImgs = methods.GetImgs(x.GImg);
            var goods = new
            {
                category_ids = x.SCCLASSID,
                is_sku = 0,
                stock = 9821,   //库存
                id = x.GID,
                title = x.GName,
                content = x.GContent,
                l = x.GName,
                x.SCCLASSID,
                images = GetImgs,
                image = GetImgs[0],
                original_price = x.GPriceYJ,
                price = x.GPrice,
                sales = x.GSales,
                x.GSort

            };

                listjson.Add(new
                {
                     id = 1212,
                user_id = 9,
                goods_id = 1,
                goods_num = 2,
                sku_price_id = 1,
                goods,
                sku_price = new {
                    goods_id=2,
                    goods_sku_id_arr="",
                    goods_sku_ids="",
                        price="11.00"
                },

            

                    });
            };

           


     


            var  code = 1;
            var  msg = "获得购物车";
            var   time = DateTime.Now;

            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time,data=listjson}));



        }


        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


    }





    public bool IsReusable {
        get {
            return false;
        }
    }

}